<?php
namespace Admin\Controller;
use Think\Controller;
class CompanyController extends BaseController {

	//绑定ERP
	public function bind_erp(){
		$m=M('User');
		$list=$m->where(array('owner_status'=>0,'status'=>1))->select();
		$this->assign('list',$list);
		$this->display();
	}

	public function add_emslog(){
		$m=M('User');
		$param=I('param.','','trim');
		// dump($param);
		$user_id=$param['user_id'];
		$id=$param['id'];
		$m_info=$m->where(array('id'=>$user_id))->find();
		$db_name='erp_'.$m_info['username'];
		$p = M('EmsLog',C('DB_PREFIX_T'), C('DB_TYPE') . '://' . C('DB_USER') . ':' . C('DB_PWD') . '@' . C('DB_HOST') . ':' . C('DB_PORT') . '/' . $db_name);
		$data['text']=$param['text'];
		$data['order_id']=$param['order_id'];
		$data['add_time']=time();
		$res=$p->add($data);
		if($res){
			$this->success('添加成功');
		}
	}
	public function del_emslog(){
		$m=M('User');
		$param=I('param.','','trim');
		$user_id=$param['user_id'];
		$id=$param['id'];
		$m_info=$m->where(array('id'=>$user_id))->find();
		$db_name='erp_'.$m_info['username'];
		$p = M('EmsLog',C('DB_PREFIX_T'), C('DB_TYPE') . '://' . C('DB_USER') . ':' . C('DB_PWD') . '@' . C('DB_HOST') . ':' . C('DB_PORT') . '/' . $db_name);
		$map['id']=$id;
		$status=$m->where($map)->delete();

		if($status!==false){
            echo "y";
        }else{
            echo "操作失败";
        }
	}
	public function ems_log(){
		$m=M('User');
		$param=I('param.','','trim');
		// dump($param);
		$user_id=$param['user_id'];
		$order_id=$param['order_id'];
		$m_info=$m->where(array('id'=>$user_id))->find();
		$db_name='erp_'.$m_info['username'];
		$p = M('EmsLog',C('DB_PREFIX_T'), C('DB_TYPE') . '://' . C('DB_USER') . ':' . C('DB_PWD') . '@' . C('DB_HOST') . ':' . C('DB_PORT') . '/' . $db_name);
		$emslog_list=$p->where(array('order_id'=>$order_id))->select();
		// dump($emslog_list);
		$this->assign('emslog_list',$emslog_list);
		$this->display();
	}
	
	//基本配置
	public function config($user_id){
		$param=I('param.','','trim');
		$user=M('User');
		$username=$user->where(array('id'=>$user_id))->getField('username');
		$db_name=C('DB_PREFIX_T').$username;
		$config=M('Config',C('DB_PREFIX_T'), C('DB_TYPE') . '://' . C('DB_USER') . ':' . C('DB_PWD') . '@' . C('DB_HOST') . ':' . C('DB_PORT') . '/' . $db_name);
		$c = M('ConfigErp');
		
		$val=$param['val'];
        if(!empty($val)){
            $where['name|en_name|value']=array('like',"%$val%");
        }
		$where['cate']=2;
        $count      = $c->where($where)->count();
        $Page       = new \Think\Page($count,20);
        $show       = $Page->show();
        $list = $c->where($where)->limit($Page->firstRow.','.$Page->listRows)->order("id desc")->select();
		foreach($list as $k=>$v){
			$list[$k]['value']=$config->where(array('en_name'=>$v['en_name']))->getField('value');
		}
		// dump($config);die;
        $this->assign('list',$list);
        $this->assign('page',$show);
        $this->assign('count',$count);
        $this->display();
	}
	
	public function ems(){
		$m=M('User');
		$param=I('param.','','trim');
		$user_id=$param['user_id'];
		$m_info=$m->where(array('id'=>$user_id))->find();
		$db_name='erp_'.$m_info['username'];
		$p = M('Pushorder',C('DB_PREFIX_T'), C('DB_TYPE') . '://' . C('DB_USER') . ':' . C('DB_PWD') . '@' . C('DB_HOST') . ':' . C('DB_PORT') . '/' . $db_name);
		
		$order_no=$param['order_no'];
        if(!empty($order_no)){
            $where['order_no']=array('like',"%$order_no%");
        }
		$logistics_no=$param['logistics_no'];
        if(!empty($logistics_no)){
            $where['logistics_no']=array('like',"%$logistics_no%");
        }
        $count      = $p->where($where)->count();
        $Page       = new \Think\Page($count,15);
        $show       = $Page->show();
        $list = $p->where($where)->limit($Page->firstRow.','.$Page->listRows)->order("id desc")->select();

        $this->assign('list',$list);
        $this->assign('page',$show);
        $this->assign('count',$count);
        $this->display();
	}

	public function confirm_bind_erp(){
		$m=M('User');
		$ids=I('ids');
		$ids=explode(',',$ids);
		$erp_code_zhu=I('erp_code');
		foreach($ids as $k=>$v){
			$m_info=$m->where(array('id'=>$v))->find();
			$erp_code=$m_info['erp_code'];
			
			if(empty($erp_code)){
				$data['erp_code']=$erp_code_zhu;
			}else{
				$arr=$erp_code.','.$erp_code_zhu;
				$arr=explode(',',$arr);
				$arr = array_unique($arr);
				$arr = array_values($arr);
				$data['erp_code']=implode(',',$arr);
			}
			$data['owner_status']=1;
			$res=$m->where(array('id'=>$v))->save($data);
			if($res===false){
				$this->error('更新出错');
			}else{
				//同步角色
				continue;
			}
		}
		$this->success('更新成功');
	}
	public function examined(){
		$ids=I('ids');
		$map['id']=array('in',$ids);
		$val=I('val');
		$data['status']=$val;
		$res=M('User')->where($map)->save($data);
		// echo M('User')->getlastsql();
		if($res!==false){
			alert(1,'成功');
		}else{
			alert(0,'失败');
		}
	}
	//绑定角色
	public function bind_role(){
		$m=M('DepartmentCompany');
		$list=$m->select();
		$this->assign('list',$list);
		$this->display();
	}
	public function confirm_bind_role(){
		$m=M('User');
		$ids=I('ids');
		$ids=explode(',',$ids);
		$role_id=I('role_id');
		foreach($ids as $k=>$v){
			$data['department_id']=$role_id;
			$res=$m->where(array('id'=>$v))->save($data);
			if($res===false){
				$this->error('更新出错');
			}else{
				$user_info=$m->find($v);
				$result=$this->pushDepartment($user_info['username'],$role_id);//同步角色
				// dump($result);
				if(!$result){
					$this->error('同步角色权限出错');
				}
				continue;
			}
		}
		$this->success('更新成功');
	}
	//同步对应erp角色权限
	public function confirm_bind_role_company($ids,$role_id){
		$m=M('User');
		$ids=explode(',',$ids);
		foreach($ids as $k=>$v){
			// dump($ids);
			$data['department_id']=$role_id;
			$res=$m->where(array('id'=>$v))->save($data);
			// echo $m->getlastsql();
			if($res===false){
				return 0;//更新出错
			}else{
				$user_info=$m->find($v);
				$result=$this->pushDepartment($user_info['username'],$role_id);//同步角色
				// dump($result);
				if(!$result){
					return 0;//同步角色权限出错
				}
				continue;
			}
		}
		return 1;//更新成功
	}
	//同步角色权限
	public function pushDepartment($username,$d_id){
		$m=M('DepartmentCompany');
		$n=M('RootCompany');
		$db_name=C('DB_PREFIX_T').$username;
		$r=M('Root', C('DB_PREFIX_T'), C('DB_TYPE') . '://' . C('DB_USER') . ':' . C('DB_PWD') . '@' . C('DB_HOST') . ':' . C('DB_PORT') . '/' . $db_name);
		$m_info=$m->find($d_id);
		$root_group_id=explode(',',$m_info['root_group_id']);
		$map['id']=array('in',$root_group_id);
		$root_list=$n->where($map)->select();
		foreach($root_list as $k=>$v){
			$dataList[] = $v;
		}
		$sql = 'truncate table '.$db_name.'.'.C('DB_PREFIX_T').'root';
		$stat=M()->execute($sql);//清空表
		$res=$r->addAll($dataList);
		return $res;
	}
    public function index(){
		$name=I("name");
        if(!empty($name)){
            $where['company']=array('like',"%$name%");
        }
		
        $user = M('user');
		$department=M('DepartmentCompany');
        $count      = $user->where($where)->count();
        $Page       = new \Think\Page($count,15);
        $show       = $Page->show();
        $list = $user->where($where)->limit($Page->firstRow.','.$Page->listRows)->order("id desc")->select();
		// echo $user->getlastsql();
		foreach($list as $k=>$v){
			$department_name=$department->where(array('id'=>$v['department_id']))->find();

			$list[$k]['department_name']=$department_name['name'];

			$list[$k]['main_erp']=$user->field('username,company')->where(array('id'=>array('in',$v['erp_code'])))->select();
		}
		// dump($list);
        $this->assign('list',$list);
        $this->assign('page',$show);
        $this->assign('count',$count);
        $this->display();
    }
    public function warehouse($id){
        if($id==''){
            alert(0,'操作有误');
        }
        $warehouse_group_id=M('user_warehouse')->where("user_id='".$id."'")->getField('warehouse_group_id');
        $group_id=explode(',',$warehouse_group_id);
        $warehouse=M('warehouse')->select();
        foreach($warehouse as $k=>$v){
            if(in_array($v['id'],$group_id)){
                $warehouse[$k]['checked']=1;
            }
        }
        $this->assign('list',$warehouse);
        $this->assign('user_id',$id);
        $this->display();
    }
    public function warehouseEditD($id,$user_id){
        if($id==''){
            alert(0,'操作有误');
        }
        $group_id=explode('@',$id);
        $id='';
        foreach($group_id as $v){
            if($v!==''){
                $id.=','.$v;
            }
        }
        $data['warehouse_group_id']=ltrim($id,',');
        $data['operator']=session('admin');
        if(M("user_warehouse")->where("user_id='".$user_id."'")->count()>0){
            $result= M("user_warehouse")->where("user_id='".$user_id."'")->save($data);
        }else{
            $data['user_id']=$user_id;
            $result= M("user_warehouse")->where("user_id='".$user_id."'")->add($data);
        }
        if($result){
            alert(1,'操作成功');
        }else{
            alert(0,'操作失败');
        }
    }
    public function addD($company,$username,$nick_name,$user_code,$user_key,$pwd,$pwd2,$email){
        if($company==''){
            alert(0,'公司名称不能为空');
        }
        if($username==''){
            alert(0,'用户名不能为空');
        }
		if($nick_name==''){
            alert(0,'昵称不能为空');
        }
		if($user_code==''){
            alert(0,'user_code不能为空');
        }
		if($user_key==''){
            alert(0,'user_key不能为空');
        }
        if($pwd==''){
            alert(0,'密码不能为空');
        }
        if($pwd2!=$pwd){
            alert(0,'两次密码不相同');
        }
        if($email==''){
            alert(0,'E-mail不能为空');
        }
        // if($sex==''){
            // alert(0,'性别不能为空');
        // }
        // if($name==''){
            // alert(0,'姓名不能为空');
        // }
        if(!email($email)){
            alert(0,'邮箱地址错误');
        }
        if(!mobile($username)){
            alert(0,'手机号码错误');
        }
        if(M("user")->where("username='".$username."'")->count()>=1){
            alert(0,'用户名已经存在！');
        }
		if(M("user")->where("nick_name='".$nick_name."'")->count()>=1){
            alert(0,'昵称已经存在！');
        }
		if(M("user")->where("user_code='".$user_code."'")->count()>=1){
            alert(0,'user_code已经存在！');
        }
		if(M("user")->where("user_key='".$user_key."'")->count()>=1){
            alert(0,'user_key已经存在！');
        }
        if(M("user")->where("company='".$company."'")->count()>=1){
            alert(0,'公司名称已经存在！');
        }
        if(M("user")->where("email='".$email."'")->count()>=1){
            alert(0,'电子邮箱已经存在！');
        }
        $data['salt']=rand(10000,99999);
        $data['username']=$username;
		$data['nick_name']=$nick_name;
		$data['user_code']=$user_code;
		$data['user_key']=$user_key;
        $data['company']=$company;
        $data['password']=md5($pwd.$data['salt']);
        // $data['name']=$name;
        $data['email']=$email;
        // $data['sex']=$sex;
        $data['operator']=session('admin');
        $result=M("user")->add($data);
        if($result){
			$reg=A('Company/Reg');
            if($reg->createDb(C('DB_PREFIX_T').$username)){
                alert(1,'添加成功');
            }else{
                alert(0,'添加失败，请重试');
            }
        }else{
            alert(0,'添加失败，请重试');
        }
    }
    public function add(){
        $this->display();
    }
    public function edit($id){
        if($id=='' || !is_numeric($id)){
            alert(0,'操作有误');
        }
        $list=M('user')->find($id);
        if(!$list){
            alert(0,'操作有误');
        }else{
            $this->assign('list',$list);
            $this->display();
        }
    }
	public function add_config(){
		$this->display();
	}
	public function addD_config($user_id,$name,$en_name,$value){
        if($user_id=='' || !is_numeric($user_id)){
            alert(0,'操作有误');
        }
		$m=M('User');
		$m_info=$m->where(array('id'=>$user_id))->find();
		$db_name='erp_'.$m_info['username'];
		$p = M('Config',C('DB_PREFIX_T'), C('DB_TYPE') . '://' . C('DB_USER') . ':' . C('DB_PWD') . '@' . C('DB_HOST') . ':' . C('DB_PORT') . '/' . $db_name);
		
		$data['en_name']=$en_name;
		$data['name']=$name;
		$data['value']=$value;
		$map['en_name']=$en_name;
		
        $detail=$p->where($map)->find();
        if(!$detail){
			$res=$p->add($data);
			if(!$res){
				alert(0,'添加失败！');
			}else{
				alert(1,'添加成功！');
			}
        }else{
            alert(0,'此变量名称已经存在！');
        }
    }
	public function edit_config($id,$user_id){
        if($id=='' || !is_numeric($id)){
            alert(0,'操作有误');
        }
		$param=I('param.','','trim');
		$c = M('ConfigErp');
		$m=M('User');
        $detail=$c->find($id);
		$m_info=$m->where(array('id'=>$user_id))->find();
		$db_name=C('DB_PREFIX_T').$m_info['username'];
		$p = M('Config',C('DB_PREFIX_T'), C('DB_TYPE') . '://' . C('DB_USER') . ':' . C('DB_PWD') . '@' . C('DB_HOST') . ':' . C('DB_PORT') . '/' . $db_name);
		
        if(!$detail){
            alert(0,'操作有误');
        }else{
			$detail['value']=$p->where(array('en_name'=>$detail['en_name']))->getField('value');
            $this->assign('detail',$detail);
            $this->display();
        }
    }
	public function editD_config($en_name,$name,$value,$user_id){
        if($name==''){
            alert(0,'变量名称不能为空');
        }
        if($value==''){
            alert(0,'值不能为空');
        }
		if($en_name==''){
            alert(0,'英文名称不能为空');
        }
		if($user_id==''){
            alert(0,'没有id');
        }
        $m=M('User');
		$param=I('param.','','trim');
		$user_id=$param['user_id'];
		$m_info=$m->where(array('id'=>$user_id))->find();
		$db_name=C('DB_PREFIX_T').$m_info['username'];
		$p = M('Config',C('DB_PREFIX_T'), C('DB_TYPE') . '://' . C('DB_USER') . ':' . C('DB_PWD') . '@' . C('DB_HOST') . ':' . C('DB_PORT') . '/' . $db_name);
		$has=$p->where(array('en_name'=>$en_name))->count();
		
		$data=array();
		$data['name']=$name;
		$data['value']=$value;
		$data['en_name']=$en_name;	
		if($has){	//存在则更新数据
			$result=$p->where(array('en_name'=>$en_name))->save($data);
			if($result!==false){
				alert(1,'修改成功');
			}else{
				alert(0,'修改失败，请重试');
			}
		}else{	//不存在则新增数据
			$result=$p->add($data);
			if($result){
				alert(1,'修改成功');
			}else{
				alert(0,'修改失败，请重试');
			}
		}
        
    }
	public function del_config($id,$user_id){
        if($id==''){
            alert(0,'操作有误');
        }
		$m=M('User');
		$param=I('param.','','trim');
		$user_id=$param['user_id'];
		$m_info=$m->where(array('id'=>$user_id))->find();
		$db_name='erp_'.$m_info['username'];
		$p = M('Config',C('DB_PREFIX_T'), C('DB_TYPE') . '://' . C('DB_USER') . ':' . C('DB_PWD') . '@' . C('DB_HOST') . ':' . C('DB_PORT') . '/' . $db_name);
		
        $result= $p->where(array('id'=>$id))->delete();
        if($result){
            alert(1,'删除成功');
        }else{
            alert(0,'删除失败');
        }
    }
    public function editD($id,$company,$pwd,$pwd2,$email){
        if($company==''){
            alert(0,'公司名称不能为空');
        }
        if($email==''){
            alert(0,'E-mail不能为空');
        }

        if(!email($email)){
            alert(0,'邮箱地址错误');
        }
        if(M("user")->where("company='".$company."' and id<>'".$id."'")->count()>=1){
            alert(0,'公司名称已经存在！');
        }
        if(M("user")->where("email='".$email."' and id<>'".$id."'")->count()>=1){
            alert(0,'电子邮箱已经存在！');
        }
        $data['company']=$company;
        if($pwd!=''){
            if($pwd2!=$pwd){
                alert(0,'两次密码不相同');
            }
            $data['salt']=rand(10000,99999);
            $data['password']=md5($pwd.$data['salt']);
        }
        // $data['name']=$name;
        $data['email']=$email;
        $data['sex']=$sex;
        $data['operator']=session('admin');
        $result=M("user")->where(array('id'=>$id))->save($data);
        if($result){
            alert(1,'修改成功');
        }else{
            alert(0,'修改失败，请重试');
        }
    }
    public function del($id){
        if($id==''){
            alert(0,'操作有误');
        }
        $group_id=explode('@',$id);
        $i=0;
        foreach($group_id as $id){
            $username=M("user")->where("id='".$id."'")->getField('username');
			$has_db=has_db(C('DB_PREFIX_T').$username);
			if($has_db){
				$true=M()->execute("drop database ".C('DB_PREFIX_T').$username);
				if($true){
					$result= M("user")->delete(ltrim($id,','));
					$i+=$result*1;
				}
			}else{
				$result= M("user")->delete(ltrim($id,','));
				$i+=$result*1;
			}
        }
        if(count($group_id)==$i){
            alert(1,'全部删除成功');
        }elseif($i>0){
            alert(1,'删除'.$i."个/共".count($group_id)."个");
        }else{
            alert(0,'删除失败');
        }
    }
	//升级
	public function updateAll(){
		$m=M('User');
		$list=$m->order('id asc')->select();
		require_once('./cloudAPP/Admin/Common/DBManage.class.php');
		foreach($list as $k=>$v){
			$dbname=C('DB_PREFIX_T').$v['username'];//数据库名称
			echo "<div style='font-size:12px;'><br>当前操作erp：".$v['company']."<br><br><br>";
			//使用读取写入方式导入
			$db = new \DBManage(C('DB_HOST'),C('DB_USER'),C('DB_PWD'),$dbname,'utf8');
			//导入
			$db->restore('./data/ue.sql');
			unset($db);
		}
		
		$dbname=C('DB_PREFIX_T').'main';//数据库名称
		echo "<div style='font-size:12px;'><br>当前操作erp：默认数据库.<br><br><br>";
		//使用读取写入方式导入
		$db = new \DBManage(C('DB_HOST'),C('DB_USER'),C('DB_PWD'),$dbname,'utf8');
		//导入
		$db->restore('./data/ue.sql');
		unset($db);
		@unlink('./data/update.sql');//删除文件
    }
	//清空
	public function truncateAll(){
		$m=M('User');
		$id=I('id');
		$user_info=$m->where(array('id'=>$id))->find();
		require_once('./cloudAPP/Admin/Common/DBManage.class.php');
		$dbname=C('DB_PREFIX_T').$user_info['username'];//数据库名称
		echo "<div style='font-size:12px;'><br>当前操作erp：".$user_info['company']."<br><br><br>";
		//使用读取写入方式导入
		$db = new \DBManage(C('DB_HOST'),C('DB_USER'),C('DB_PWD'),$dbname,'utf8');
		//导入
		$db->restore('./data/truncate_erp.sql');
		unset($db);
    }
	
	//角色列表
    public function department(){
        $f=C('DB_PREFIX');
        $list = M('DepartmentCompany')->order('created_at desc')->select();
        $this->assign('list',$list);
        $this->display();
    }
	public function department_add(){
		$root=M('RootCompany')->order("sort")->select();
        $new_arr=array();
		foreach($root as $k=>$v){
            if($v['pid']==0){//顶级菜单
                foreach($root as $j=>$u){
					if($v['id']==$u['pid']){
						foreach($root as $js=>$us){
							if($u['id']==$us['pid']){
								foreach($root as $jss=>$uss){
									if($us['id']==$uss['pid']){
											$us['child'][]=$uss;
									}
								}
								$u['child'][]=$us;
							}
						}
						$v['child'][]=$u;
					}
				}
				$new_arr[]=$v;
            }
        }
		// dump($new_arr);
		// die;
		$this->assign('list',$new_arr);
        $this->display();
    }
	public function department_addD($name,$group_id){
        $this->p = M('RootCompany');
        if($name==''){
            alert(0,'部门名称为空');
        }
        if($group_id==''){
            alert(0,'权限不能为空');
        }
        $count=$this->p->where("name='".$name."'")->count();
        if($count>0){
            alert(0,'名称已经存在');
        }
        //////权限检查，是否具备这些权限
        $arr_id=explode(',',$group_id);
        foreach($arr_id as $v){
            if(!is_numeric($v)){
                alert('操作有误');
            }
        }
        $where['id']=array('IN',$arr_id);
        $result=$this->p->where($where)->getField('name',true);
        if(count($result)!=count($arr_id)){
            alert('操作有误');
        }
        $data['name']=$name;
        $massage=session('admin');
        $data['operator']=$massage;
        $this->product = M('DepartmentCompany');
        $data['root_group_id']=$group_id;
        $result=$this->product->add($data);
		// echo $this->product->getlastsql();
        if($result){
            alert(1,'添加成功');
        }else{
            alert(0,'添加失败');
        }
    }
    public function department_edit($id){
        if($id==''){
            echo "错误";
        }
		
		$root=M('RootCompany')->order("sort")->select();
		$this->product = M('DepartmentCompany');
		$this->data=$this->product->find($id);
        $root_id=$this->product->where(array('id'=>$id))->getField('root_group_id');
        $arr_root=explode(',',$root_id);
        $new_arr=array();
		foreach($root as $k=>$v){
			if(in_array($v['id'],$arr_root)){
				$v['checked']=1;
			}
            if($v['pid']==0){//顶级菜单
                foreach($root as $j=>$u){
					if(in_array($u['id'],$arr_root)){
						$u['checked']=1;
					}
					if($v['id']==$u['pid']){
						foreach($root as $js=>$us){
							if(in_array($us['id'],$arr_root)){
								$us['checked']=1;
							}
							if($u['id']==$us['pid']){
								foreach($root as $jss=>$uss){
									if(in_array($uss['id'],$arr_root)){
										$uss['checked']=1;
									}
									if($us['id']==$uss['pid']){
											$us['child'][]=$uss;
									}
								}
								$u['child'][]=$us;
							}
						}
						$v['child'][]=$u;
					}
				}
				$new_arr[]=$v;
            }
        }
        $this->assign('list',$new_arr);
        $this->display();
    }
    public function department_editD($id,$group_id){
        $this->p = M('RootCompany');
        if($group_id==''){
            alert(0,'权限不能为空');
        }
        //////权限检查，是否具备这些权限
        $arr_id=explode(',',$group_id);
		// dump($arr_id);
		// die;
        foreach($arr_id as $v){
            if(!is_numeric($v)){
                alert('操作有误');
            }
        }
        $where['id']=array('IN',$arr_id);
        $result=$this->p->where($where)->getField('name',true);
        if(count($result)!=count($arr_id)){
            alert('操作有误');
        }
        $massage=session('admin');
        $data['operator']=$massage;
        $this->product = M('DepartmentCompany');
        $data['root_group_id']=$group_id;
        $result=$this->product->where(array('id'=>$id))->save($data);
        if($result){
            alert(1,'修改成功');
        }else{
            alert(0,'修改失败');
        }
    }
    public function department_del($id){
        if($id==''){
            alert(0,'操作有误');
        }
        ///////$id=1@2@3
        $group_id=explode('@',$id);
        $id=implode(',',$group_id);
        $result=M('DepartmentCompany')->delete($id);
        if($result){
            alert(1,'成功删除了'.$result.'条数据，共'.count($group_id).'条');
        }else{
            alert(0,'删除失败');
        }
    }

	
}